<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="cn.edu.scau.cmi.carol.javabean.Conn" %>
<%@ page import="cn.edu.scau.cmi.carol.javabean.User" %>
<%@ page import="cn.edu.scau.cmi.carol.sex.Sex" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%! int num=0;
synchronized void add(){
	num++;
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>checkAllInformation</title>
</head>
<body>
<%
try{
	Connection conn=Conn.connect();
	String selectsql="select * from student";
	Statement s=conn.createStatement();
	ResultSet rs=s.executeQuery(selectsql);
	
	List<User> list=new ArrayList<>();	
    while(rs.next()){ 
    User user=new User();
    user.setStudentID(rs.getInt(1));
    user.setName(rs.getString(2));
	user.setSex(Sex.sexToString(rs.getInt(3)));
	user.setAge(rs.getInt(4));
	user.setPassword(rs.getString(5));
	list.add(user);
	add();
    }
    rs.close();
    s.close();
    conn.close();
    
%>
Total:<%=num%>person.
<table>
<tr>
<th>studentID</th>
<th>name</th>
<th>sex</th>
<th>age</th>
<th>password</th>
</tr>
<% 
 if(list == null || list.size() < 1){
	out.print("No_information.");
}
else{ 
	for (User user1: list) {
%>
<tr>
<td><%=user1.getStudentID() %></td>
<td><%=user1.getName()%></td>
<td><%=user1.getSex() %></td>
<td><%=user1.getAge() %></td>
<td><%=user1.getPassword() %></td>
</tr>

<%
}
}
}
catch(Exception e){
	e.printStackTrace();
}
%>
</table>
</body>
</html>